package com.framework.modules.base.service.impl;

import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.framework.common.utils.PageUtils;
import com.framework.common.utils.Query;

import com.framework.modules.base.dao.GiftDao;
import com.framework.modules.base.entity.GiftEntity;
import com.framework.modules.base.service.GiftService;


@Service("giftService")
public class GiftServiceImpl extends ServiceImpl<GiftDao, GiftEntity> implements GiftService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        EntityWrapper wrapper=new EntityWrapper<GiftEntity>();
        if(params.containsKey("category")) {
            String category = params.get("category").toString();
            if (!"all".equals(category)) {
                wrapper.eq("category", params.get("category"));
            }
        }
        Page<GiftEntity> page = this.selectPage(
                new Query<GiftEntity>(params).getPage(),
                wrapper.orderBy("display_order")
        );

        return new PageUtils(page);
    }

}
